package com.zyf.springcloud.controller;

import com.zyf.springcloud.result.Result;
import com.zyf.springcloud.service.impl.ListServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/list")
public class ListController {
    @Autowired
    ListServiceImpl listService;

    @GetMapping("/getExcel")
    public Result getExcel(){
        return listService.getExcel();
    }
    @GetMapping("/getOne/{id}")
    public Result getOne(@PathVariable int id) {
        return Result.ok(listService.getById(id));
    }
    @GetMapping("/getCategory")
    public Result getCategory(){
        return listService.getCategory();
    }
    @GetMapping("/getAll")
    public Result getAll(){
     List<com.zyf.springcloud.model.List> list=listService.getAll();
     for (com.zyf.springcloud.model.List item:list){
         listService.getChildren(item);
     }
     return Result.ok(list);
    }

}
